home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_tut / fibtest.ada < prev    next >
Text File  |  1996-01-30  |  912b  |  32 lines

  1. with Text_IO; use Text_IO;
  2. procedure Fibtest is
  3.    Passed : Boolean := True;
  4.    function Fib(N : in Positive) return Positive is separate;
  5.    procedure Compare (N : in Positive; Right_Answer : in Positive) is
  6.       package Int_IO is new Integer_IO(Integer); use Int_IO;
  7.       My_Answer : Positive := Fib(N);
  8.    begin
  9.       if My_Answer /= Right_Answer then
  10.          Put("N:");  Put(N);
  11.          Put("          My answer:");  Put(My_Answer);
  12.          Put("          Right answer:");  Put(Right_Answer);
  13.          New_Line;
  14.          Passed := False;
  15.       end if;
  16.    end Compare;
  17. begin
  18.    Compare(1, 1);
  19.    Compare(2, 1);
  20.    Compare(3, 2);
  21.    Compare(4, 3);
  22.    Compare(5, 5);
  23.    Compare(6, 8);
  24.    Compare(7, 13);
  25.    Compare(10, 55);
  26.    Compare(15, 610);
  27.    Compare(20, 6765);
  28.    if Passed then
  29.       Put_Line("Congratulations, you completed the assignment!");
  30.    end if;
  31. end Fibtest;
  32.